home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 2 / CD ACTUAL VOL 2.iso / slakware / makeflop < prev    next >
Encoding:
Text File  |  1995-09-10  |  14.1 KB  |  516 lines

  1. #!/bin/sh
  2. # Copyright (C) 1993 David Niemi
  3. # The author places no restrictions on the use of this script.
  4.  
  5. #
  6. # Partial port to HP/UX by Michel Eyckmans (MCE) <eyckmans@imec.be>.
  7. # Only DOS formatting capability is missing.
  8. #
  9.  
  10. # this script requires mtools (except on HP/UX). If you don't have
  11. # it, get it from prep.ai.mit.edu: /pub/gnu or other GNU repositories.
  12.  
  13. # modified by Patrick Volkerding (volkerdi@mhd1.moorhead.msus.edu)
  14. # and IBM RS6000 compatibility by Torben N. Rasmussen (tnr@csd.cri.dk)
  15.  
  16. # Extensive cleanup/functionality additions by John Plocher (plocher@sun.com)
  17. # Provides interactive prompts to make disk mastering easier
  18. # Run this script in the directory containing the directories "a" "ap" ...
  19.  
  20. # Edit this as needed
  21.  
  22. MTOOLS=/usr
  23.  
  24. # Global defaults
  25.  
  26. export PATH LD_LIBRARY_PATH
  27. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/ucblib:$MTOOLS/lib
  28. PATH=$PATH:$MTOOLS/bin
  29.  
  30. format=$MTOOLS/bin/mformat
  31. copy=$MTOOLS/bin/mcopy
  32. erase=$MTOOLS/bin/mdel
  33. eject=eject
  34.  
  35. dollar='$'
  36.  
  37. set -e  # Exit on error
  38.  
  39. # Number of disks in each set
  40.  
  41. a=5
  42. ap=5
  43. d=10
  44. e=6
  45. f=2
  46. k=5
  47. n=4
  48. q=15
  49. t=9
  50. tcl=1
  51. x=16
  52. xap=4
  53. xd=3
  54. xv=3
  55. y=4
  56.  
  57. # Descriptions of the packages
  58.  
  59. at="Base Linux"
  60. apt="Text based applications"
  61. dt="Program Development/GCC c|c++|obj-C kernel source and more"
  62. et="Emacs"
  63. ft="FAQs"
  64. kt="Kernel source and includes"
  65. nt="Networking/UUCP/Mail/News"
  66. qt="Extra Kernel Images/Source"
  67. tt="TeX"
  68. tclt="Tcl Script Language/Tk Toolkit"
  69. xt="XFree86 X Window System"
  70. xapt="X Applications"
  71. xdt="X11 Server Development"
  72. xvt="XView (OpenLook Window Manager)"
  73. yt="Games (including DOOM)"
  74.  
  75. PACKAGES="a ap d e f k n q t tcl x xap xd xv y"
  76.  
  77. ##########################################################################
  78. # These routines are only used on an hp/ux host
  79. #
  80. hpuxdosformat () {
  81.   echo "*** Warning *** No format on HP/UX, trying without !"
  82.   ## The mediainit utility can do a low level format, but there
  83.   ## seems to be no way to create an MS-DOS filesystem.
  84.   return 0
  85. }
  86.  
  87. hpuxdoserase() {
  88.   # HACK: We can ignore our $* here, since we just want to remove
  89.   #       everything anyway. HP/UX dos commands don't know about
  90.   #       filename completion, so we have to do it the hard way.
  91.   files=`dosls $FD`
  92.   if [ "$files" != '' ]
  93.   then
  94.       dosrm -r $files     
  95.   fi
  96. }
  97.  
  98. hpuxdoswrite() {
  99.   for file in $*
  100.   do
  101.       if [ "$file" != "$FD" ]
  102.       then
  103.       echo Copying $file ...
  104.           doscp -f $file $FD`basename $file`
  105.       fi
  106.   done
  107.   return 0
  108. }
  109.  
  110. hpuxeject(){
  111.   echo "Please eject floppy disk now"
  112. }
  113.  
  114. #       (End of HP/UX specific routines)
  115. ##########################################################################
  116.  
  117. ##########################################################################
  118. # These routines are only used on an aix host
  119. #
  120. aixdosformat () {
  121.   Echo "Formatting..."
  122.   dosformat > /dev/null << EOI
  123.  
  124. n
  125. EOI
  126.   echo "done"
  127.   return 0
  128. }
  129.  
  130. aixdoswrite() {
  131.   for file in $*; do
  132.     if [ "$file" != "$FD" ]; then
  133.       echo Copying $file ...
  134.       doswrite $file `basename $file` > /dev/null
  135.     fi
  136.   done
  137.   return 0
  138. }
  139.  
  140. aixeject(){
  141.   echo "Please eject floppy disk now"
  142. }
  143. #       (End of AIX specific routines)
  144. ##########################################################################
  145.  
  146. # Linux specific formatting routines:
  147.  
  148. Linuxaformat() {
  149.     fdformat /dev/fd0H1440
  150.         if [ $? = 0 ]; then
  151.          mformat a:
  152.         else
  153.          return 1;
  154.         fi
  155.         return $?
  156. }
  157.  
  158. Linuxbformat() {
  159.     fdformat /dev/fd1H1440
  160.         if [ $? = 0 ]; then
  161.          mformat b:
  162.         else
  163.          return 1;
  164.         fi
  165.         return $?
  166. }
  167.  
  168. ##########################################################################
  169. #                       Common routines
  170. ##########################################################################
  171.  
  172. Echo() {
  173.         if [ "`echo -n `" != "'-n'" ]
  174.     then
  175.             echo -n $*' '
  176.     else
  177.             echo $*' '"\c"
  178.     fi
  179. }
  180.  
  181. ##########################################################################
  182.  
  183. Prompt() { # => diskno alldone duplicate eraseit
  184.         my_IMAGE="$1"
  185.         my_default="$2"
  186.         my_disk="$3"
  187.         my_diskno="$4"
  188.         my_maxdisk="$5"
  189.         my_series="$6"
  190.         my_descrip="$7"
  191.  
  192.         valid_answer="no"
  193.         my_need_help="yes"
  194.         imagename=$my_diskno
  195.  
  196.         while [ "$valid_answer" = "no" ]; do
  197.                 if [ "$my_need_help" = "yes" ]; then
  198.                     my_need_help="no"
  199.                     echo "__"
  200.                   if [ -z "$my_IMAGE" ]; then
  201.                     echo "[$my_disk] disk $my_diskno of $my_maxdisk (${my_descrip})"
  202.                   else
  203.                     echo "[$my_disk] ${my_descrip}"
  204.                   fi
  205.                     echo "  Please insert a blank floppy and press"
  206.                     echo "    [q]  to Quit this program"
  207.                     echo "    [h]  to show this Help message"
  208.                     echo "    [f]  to Format floppy and duplicate disk image"
  209.                     echo "    [d]  to Duplicate disk image"
  210.                   if [ -z "$my_IMAGE" ]; then
  211.                     echo "    [l]  to List the contents of disk \"$my_series$my_diskno\""
  212.                     echo "    [sd] to Skip this Disk \"$my_series$my_diskno\""
  213.                     echo "    [ss] to Skip the entire \"$my_series\" Series"
  214.                   else
  215.                     echo "    [l]  to List the possible disk images"
  216.                     echo "    [c]  to Choose a disk image"
  217.                     echo "    [s]  to Skip this disk image"
  218.                     echo "    Current image: $my_diskno"
  219.                   fi
  220.                 fi
  221.  
  222.                 Echo "__Choice: [$my_default]: "
  223.                 answer="invalid"
  224.                 read answer junk
  225.                 if [ -z "$answer" ]; then
  226.                         answer="$my_default"
  227.                 fi
  228.  
  229.                 case $answer in
  230.                 q*) echo "Quitting"; exit 0 ;;
  231.                 h*) my_need_help=yes;;
  232.                 c*)
  233.                     if [ -n "$my_IMAGE" ]; then
  234.                         Echo "$disk image: [$my_diskno]: "
  235.                         read imagename junk
  236.                         if [ -z "$imagename" ]; then
  237.                             imagename="$default_image"
  238.                         fi
  239.                         if [ ! -r "$imagename" ]; then
  240.                            echo "ERROR: \"$imagename\" is not readable."
  241.                         else
  242.                            my_diskno=$imagename
  243.                         fi
  244.                     fi;
  245.                     ;;
  246.                 l*)
  247.                     if [ -z "$my_IMAGE" ]; then
  248.                         ls -Fl $my_series$my_diskno/.??* $my_series$my_diskno/* | cut -c30-41,54-
  249.                     else
  250.                         ls -Fl $my_IMAGE | cut -c30-41,54-
  251.                     fi
  252.                     duplicate=no
  253.                     alldone=no
  254.                     eraseit=no
  255.                     ;;
  256.                 sd)
  257.                     if [ -z "$my_IMAGE" ]; then
  258.                         alldone=yes
  259.                         valid_answer=yes
  260.                     else
  261.                         echo "ERROR: Invalid entry.  Try again"
  262.                     fi
  263.                     ;;
  264.                 ss)
  265.                     if [ -z "$my_IMAGE" ]; then
  266.                         diskno=$my_maxdisk;
  267.                         alldone=yes
  268.                         valid_answer=yes
  269.                     else
  270.                         echo "ERROR: Invalid entry.  Try again"
  271.                     fi
  272.                     ;;
  273.                 s*)
  274.                     if [ -z "$my_IMAGE" ]; then
  275.                         Echo "Skip what? [d]=disk [s]=series: [d]: "
  276.                         answer="invalid"
  277.                         read answer junk
  278.                         if [ -z "$answer" ]; then
  279.                                 answer="d"
  280.                         fi
  281.                         case $answer in
  282.                                 d) alldone=yes;
  283.                                    valid_answer=yes;;
  284.                                 s) diskno=$maxdisk;
  285.                                    alldone=yes;
  286.                                    valid_answer=yes;;
  287.                                 *) echo "invalid entry - try again";;
  288.                         esac
  289.                     else
  290.                         alldone=yes
  291.                         valid_answer=yes
  292.                     fi
  293.                     ;;
  294.                 d*) duplicate=yes
  295.                     eraseit=yes
  296.                     default="d"
  297.                     valid_answer=yes
  298.                     ;;
  299.                 f*) default="f"
  300.                     if $format; then
  301.                           duplicate=yes
  302.                           eraseit=no
  303.                           valid_answer=yes
  304.                           break
  305.                     else
  306.                           echo "Error: format failed!"
  307.                           $eject
  308.                     fi
  309.                    ;;
  310.                 *)
  311.                    echo "ERROR: Invalid entry.  Try again"
  312.                    ;;
  313.                 esac
  314.         done;
  315. }
  316.  
  317. ##########################################################################
  318.  
  319. CopyImage()
  320. {
  321.     alldone=no
  322.  
  323.     echo
  324.     echo "=== $descrip ==="
  325.  
  326.     while [ "$alldone" = "no" ]; do
  327.             Prompt "$images" "f" "$disk" "$default_image" "" "" "${descrip}"
  328.             if [ "$alldone" != "no" ]; then break; fi
  329.  
  330.             if [ "$duplicate" = "yes" ]; then
  331.                 if [ -r $imagename -o -r $imagename.gz ]; then
  332.                     if [ "`basename $imagename .gz`" != "$imagename" ]; then # compressed
  333.                         gzip -cd $imagename | dd of=$device obs=18k 
  334.                         $eject
  335.                         alldone=yes
  336.                     else # uncompressed
  337.                         dd of=$device obs=18k if=$imagename 
  338.                         $eject
  339.                         alldone=yes
  340.                     fi
  341.                     break;
  342.                 else
  343.                     echo
  344.                     echo "ERROR: \"$imagename\" does not exist."
  345.                 fi
  346.             fi
  347.  
  348.     done
  349. }
  350.  
  351. ##########################################################################
  352.  
  353. CopyDisk()
  354. {
  355.     while [ "$alldone" = "no" ]; do
  356.         Prompt "" "$default" "$disk" "$diskno" "$maxdisk" "$series" "${descrip}"
  357.         if [ "$alldone" != "no" ]; then break; fi
  358.         if [ "$duplicate" = "yes" ]; then
  359.             if [ ! -d "$disk" ]; then
  360.                     echo "ERROR: Disk Image Directory \"$disk\" does not exist!"
  361.             else
  362.                     set +e
  363.                     if [ "X$eraseit" = "Xyes" ]; then
  364.                             if $erase $FD/\* 2>&1 > /dev/null; then
  365.                                 :       # All OK
  366.                             else
  367.                                 :
  368.                                 # echo "ERROR: $erase $FD/\* failed!"
  369.                                 # set -e
  370.                                 # continue
  371.                             fi
  372.                     fi
  373.                     if $copy $disk/* $FD; then
  374.                             alldone=yes
  375.                             $eject
  376.                     else
  377.                             echo "ERROR: $copy $disk/\* $FD failed!"
  378.                             $eject
  379.                             set -e
  380.                             continue
  381.                     fi
  382.                     set -e
  383.             fi
  384.         fi
  385.     done
  386. }
  387.  
  388. ########################################################################
  389.  
  390.  
  391.  
  392.  
  393. echo "########################################################################"
  394. echo "            Linux Slackware 3.0.0 disk mastering utility"
  395. echo "########################################################################"
  396. echo
  397. echo "This program should be run in the directory containing the"
  398. echo "Linux Slackware directories: $PACKAGES"
  399. echo
  400. echo "Which of the following is your target device:"
  401. echo
  402. echo "    1 - Sun floppy drive"
  403. echo "    2 - Volmgr sun floppy drive (UNTESTED)"
  404. echo "    3 - A: 3.5\" linux drive (/dev/fd0H1440)"
  405. echo "    4 - B: 3.5\" linux drive (/dev/fd1H1440)"
  406. echo "    5 - AIX RS6000 floppy drive"
  407. echo "    6 - HP/UX floppy drive"
  408. echo "    7 - Quit"
  409. echo
  410. if [ "`echo -n `" != "'-n'" ]
  411. then
  412.     echo -n "Enter your choice: [Q]: "
  413. else
  414.     echo "Enter your choice: [Q]: \c"
  415. fi
  416.  
  417. #read device junk
  418. read device;
  419. if [ -z "$device" ]; then
  420.         device="Q"
  421. fi
  422.  
  423. case "$device" in
  424.         1*|[sS]* )
  425.           FD="a:"
  426.           format="fdformat -d -f"
  427.           device=/dev/diskette
  428.           eject="eject floppy"
  429.         ;;
  430.         2*|[vV]* )
  431.           FD="a:"
  432.           format="fdformat -d -f"
  433.           device=/vol/dev/fd0
  434.           eject="eject floppy"
  435.         ;;
  436.         3*|[aA]:* )
  437.           FD="a:"
  438.           format=Linuxaformat
  439.           device=/dev/fd0H1440
  440.           eject=:
  441.         ;;
  442.         4*|[bB]:* )
  443.           FD="b:"
  444.           format=Linuxbformat
  445.           device=/dev/fd1H1440
  446.           eject=:
  447.         ;;
  448.         5*|[Aa][Ii][Xx]* )
  449.           FD="a:"
  450.           device=/dev/rfd0
  451.           format=aixdosformat
  452.           copy=aixdoswrite
  453.           eject=aixeject
  454.         ;;
  455.         6*|[Hh][Pp]* )
  456.           device=/dev/rfloppy/c201d0s0
  457.           FD=$device:
  458.           format=hpuxdosformat
  459.           copy=hpuxdoswrite
  460.       erase=hpuxdoserase
  461.           eject=hpuxeject           
  462.         ;;
  463.         [7qQ]* )
  464.           echo "Quitting"
  465.           exit 0
  466.           ;;
  467.         * )
  468.           echo "ERROR: invalid entry"
  469.           echo "Quitting"
  470.           exit 0;
  471.         ;;
  472. esac
  473.  
  474. echo "Using $FD ($device) to create floppies."
  475. echo
  476.  
  477. descrip="Slackware bootkernel disk"
  478. images="../bootdsks.*/*.gz"
  479. default_image=../bootdsks.144/modern.gz
  480. disk="Boot"
  481.  
  482. CopyImage
  483.  
  484. descrip="Slackware root/install disk"
  485. images="../rootdsks.*/*.gz"
  486. disk="Filesystem"
  487. default_image=../rootdsks.144/color144.gz
  488.  
  489. CopyImage
  490.  
  491. default="f"
  492.  
  493. for series in $PACKAGES; do
  494.         diskno=1
  495.         maxdisk=`eval echo "$dollar$series"`
  496.         descrip=`eval echo "$dollar${series}t"`
  497.  
  498.         echo
  499.         echo "=== ${descrip} ==="
  500.         echo "Making $maxdisk floppies for series \"$series\" (${descrip})"
  501.         while [ "$diskno" -le $maxdisk ]; do
  502.                 disk=$series$diskno
  503.                 alldone=no
  504.                 duplicate=no
  505.                 if [ ! -d "$disk" ]; then
  506.                         echo "ERROR: Disk Image Directory \"$disk\" does not exist!"
  507.                         alldone="yes"
  508.                 fi
  509.                 CopyDisk
  510.         diskno=`expr $diskno + 1`
  511.         done
  512. done
  513.  
  514.